package com.zero.manage.web.utils.validated;

import com.zero.manage.web.components.dto.GenDto;
import io.gitee.zerowsh.enums.ToolEnums;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


public class GenGroupSequenceProvider implements DefaultGroupSequenceProvider<GenDto> {

    @Override
    public List<Class<?>> getValidationGroups(GenDto bean) {
        List<Class<?>> defaultGroupSequence = new ArrayList<>();
        defaultGroupSequence.add(GenDto.class); // 这一步不能省,否则Default分组都不会执行了，会抛错的

        if (bean != null) { // 这块判空请务必要做
            ToolEnums.WhetherEnums download = bean.getDownload();
            if (Objects.equals(download, ToolEnums.WhetherEnums.F)) {
                defaultGroupSequence.add(GenDto.BasicPathPathGroup.class);
            }
        }
        return defaultGroupSequence;
    }
}
